package com.booter.ws.session;

import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;

/**
 * @author lcw
 * @date 2022/6/17 10:01
 */
@Slf4j
public class CustomSubProtocolWebSocketHandler extends SubProtocolWebSocketHandler {


    public CustomSubProtocolWebSocketHandler(MessageChannel clientInboundChannel,
                                             SubscribableChannel clientOutboundChannel) {
        super(clientInboundChannel, clientOutboundChannel);
    }

    @Override
    protected WebSocketSession decorateSession(WebSocketSession session) {
        CustomWebSocketSessionDecorator decorator = new CustomWebSocketSessionDecorator(session, getSendTimeLimit(), getSendBufferSizeLimit(), this);
        SessionStore.addSession(decorator);
        return decorator;
    }
}
